﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ServiceTitle.aspx.cs" Inherits="Hosting.CategoryTitle" %>

<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="obout" %>

<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="obout" %>

<asp:Content runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="js/GridMessageValid.js"></script>
<script type="text/javascript" src="js/CategoryTitle.js"></script>
<script type="text/javascript">
    function gCateTitle_BeforeClientDelete() {
        if (confirm("Are you sure to delete this Category Title and all Children?") == false) {
            return false;
        }
        return true;
    }

    function gCateTitle_Validation(sender, record) {
        var isValid = CategoryTitleValid(record.CTName, record.CTDescription);
        if (isValid == 1) {
            return true;
        }
        else if (isValid == 10) {
            getMessageAttention("Name is null or empty");
        }
        else if (isValid == 11) {
            getMessageAttention("Name is greater than 2000 characters");
        }
        else if (isValid == 20) {
            getMessageAttention("Description is greater than 2000 chareacters");
        }
        setInterval(function () { hidediv('divGridValidation'); }, 4000);
        return false;
    }
</script>
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<a href="#" id="anchorGridNotification"></a>
<div class="notification attention png_bg" id="divGridValidation" style="display:none;">
	<div id="divGridNotification" runat="server">
        <label id="GridNotificationLabel">Update status of control.</label>
	</div>
</div>
<obout:Grid id="gCateTitle" runat="server" AutoGenerateColumns="False"
    DataSourceID="ldsCateTitle" AllowFiltering="true" Serialize="false"
    AllowColumnResizing="false"
    AllowRecordSelection="false"
    OnInsertCommand="gCateTitle_InsertCommand"
    OnUpdateCommand="gCateTitle_UpdateCommand"
    OnDeleteCommand="gCateTitle_DeleteCommand" PageSizeOptions="5,10,20,50" AllowManualPaging="True" AllowMultiRecordSelection="False">

    <ScrollingSettings ScrollWidth="900px" />
    <ClientSideEvents ExposeSender="true" OnBeforeClientDelete="gCateTitle_BeforeClientDelete" OnBeforeClientInsert="gCateTitle_Validation" OnBeforeClientUpdate="gCateTitle_Validation" />

    <Columns>
        <obout:Column DataField="CTId" HeaderText="ID" ReadOnly="true" runat="server" Visible="false" Width="50px" />
        <obout:Column DataField="CTName" HeaderText="Name"  runat="server">
            <TemplateSettings EditTemplateId="tplEditName" />
        </obout:Column>
        <obout:Column DataField="CTDescription" HeaderText="Description"  runat="server" Width="380px">
            <TemplateSettings EditTemplateId="tplEditDescription" />
        </obout:Column>
        <obout:Column DataField="CTActive" HeaderText="Active" runat="server">
            <TemplateSettings EditTemplateID="tplEditActive" />
        </obout:Column>
        <obout:Column AllowEdit="true" AllowDelete="true" AllowSorting="false" />
    </Columns>
    <Templates>
        <obout:GridTemplate runat="server" ID="tplEditActive" ControlID="cbActive" ControlPropertyName="checked">
            <Template>
                <input type="checkbox" id="cbActive"/>
            </Template>
        </obout:GridTemplate>
        <obout:GridTemplate runat="server" ID="tplEditName" ControlID="txtName">
            <Template>
                <obout:OboutTextBox ID="txtName" Width="880px" runat="server" TextMode="MultiLine" Height="100px"></obout:OboutTextBox>
            </Template>
        </obout:GridTemplate>
        <obout:GridTemplate runat="server" ID="tplEditDescription" ControlID="txtDescription">
            <Template>
                <obout:OboutTextBox ID="txtDescription" Width="880px" runat="server" TextMode="MultiLine" Height="100px"></obout:OboutTextBox>
            </Template>
        </obout:GridTemplate>
    </Templates>
    <Templates>
        <obout:GridTemplate>
            <Template>
                <fieldset style="padding-left: 150px;" class="myfield">
                    <p>
                        <label for="sHCPackage">Package: </label>
                        <select class="medium-input" id="sHCPackage" datasourceid="ldsPackageAll" datatextfield="SPName"
                            datavaluefield="SPId" runat="server">
                        </select>
                    </p>
                    <p>
                        <label for="txtHCName">Name: </label>
                        <input type="text" class="medium-input" id="txtHCName" runat="server" />
                    </p>
                    <p>
                        <label for="txtHCFee">Fee: </label>
                        <input type="text" class="medium-input" value="0" id="txtHCFee" runat="server" />
                    </p>
                    <p>
                        <label for="cbHCActive">Active: </label>
                        <input type="checkBox" id="cbHCActive" runat="server" />
                    </p>
                    <p>
                        <label for="txtHCDescription">Description:</label>
                        <textarea class="medium-input" id="txtHCDescription" runat="server" rows="10" cols="1"></textarea>
                    </p>
                </fieldset>
            </Template>
        </obout:GridTemplate>
    </Templates>
    </obout:Grid>

    <asp:LinqDataSource runat="server" ID="ldsCateTitle"
    ContextTypeName="Hosting.Class.HostingDomainWebsiteDataContext"
    TableName="TBL_CategoryTitles"
    EnableInsert="true"
    EnableUpdate="true"
    EnableDelete="true"></asp:LinqDataSource>
</asp:Content>
